package org.example;

import org.apache.ibatis.session.SqlSession;
import org.example.database.SelectInfo;
import org.example.entity.*;
import org.example.utils.DateUtil;
import org.example.utils.SessionUtil;

import java.math.BigDecimal;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) throws Exception {
        SessionUtil sessionUtil = new SessionUtil("syz", "R5TukE3qsewU87tOxdVMCqKVqgfWo5lh", "syz", "127.0.0.1", 3306);
        SqlSession session = sessionUtil.getSession();
        SelectInfo selectInfo = new SelectInfo(session);
        String tableName = "goods_price_list";
        TableEntity tableInfo = selectInfo.getTableInfo(tableName);

        ProjectInfoEntity projectInfoEntity = new ProjectInfoEntity("com.syz", "E:\\Idea\\yushu\\shengyize_business");

        BasicInfoEntity basicInfoEntity = new BasicInfoEntity();
        basicInfoEntity.setCreateTime(DateUtil.getNowTimeFormat(DateUtil.TIME));
        basicInfoEntity.setAuthor("Administrator");
        String filePath = "E:\\Idea\\yushu\\shengyize_business\\src\\main\\java\\com\\syz\\mapper\\xml";


        basicInfoEntity.setEntity(new TemplateInfoEntityEntity(projectInfoEntity, tableName));
        basicInfoEntity.setDao(new TemplateInfoDaoEntity(projectInfoEntity, tableName));
        basicInfoEntity.setXml(new TemplateInfoXmlEntity(projectInfoEntity, tableName, filePath));
        basicInfoEntity.setService(new TemplateInfoServiceEntity(projectInfoEntity, tableName));
        basicInfoEntity.setServiceImpl(new TemplateInfoServiceImplEntity(projectInfoEntity, tableName));
        basicInfoEntity.setController(new TemplateInfoControllerEntity(projectInfoEntity, tableName));



        new CodeGenerate().createFile(basicInfoEntity, tableInfo);

    }
}
